package io.renren.modules.doc.dao;

import io.renren.modules.doc.entity.DenseRagEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 向量检索DAO
 */
@Mapper
public interface DenseRagDao extends BaseMapper<DenseRagEntity> {
    
    /**
     * 相似度检索
     * @param embeddings 查询向量嵌入
     * @param limit 返回结果数量限制
     * @return 相似度排序的结果列表
     */
    @Select("SELECT * FROM denserag WHERE embeddings IS NOT NULL ORDER BY embeddings <-> #{embeddings}::vecf16 LIMIT #{limit}")
    List<DenseRagEntity> searchSimilar(@Param("embeddings") byte[] embeddings, @Param("limit") int limit);
}
